package com.meida.module.bbs.provider.handler;

import com.meida.common.base.entity.EntityMap;
import com.meida.common.mybatis.interceptor.GetInterceptor;
import com.meida.common.mybatis.query.CriteriaQuery;
import com.meida.module.bbs.provider.service.BbsCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 帖子详情扩展
 *
 * @author zyf
 */
@Component("bbsContentGetHandler")
public class BbsContentGetHandler implements GetInterceptor {

    @Autowired
    private BbsCommentService commentService;

    @Override
    public void prepare(CriteriaQuery cq, EntityMap params) {

    }

    @Override
    public void complete(CriteriaQuery cq, EntityMap map) {
        Long contentId = map.getLong("contentId");
        List<EntityMap> commentList = commentService.listByContentId(contentId, 10);
        map.put("commentList", commentList);
    }
}
